﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Settings Flyout item template is documented at http://go.microsoft.com/fwlink/?LinkId=273769

namespace CharacterMap
{
    public sealed partial class PreferencesFlyout : SettingsFlyout
    {
        public PreferencesFlyout()
        {
            this.InitializeComponent();
            toggleTheme.IsOn = MessageService.Current.CurrentTheme == ElementTheme.Dark;
            toggleTheme.Toggled += toggleTheme_Toggled;

            toggleDataCollection.IsOn = MessageService.Current.AllowDataCollection;
            toggleDataCollection.Toggled += toggleDataCollection_Toggled;
        }

        void toggleDataCollection_Toggled(object sender, RoutedEventArgs e)
        {
            MessageService.Current.AllowDataCollection = toggleDataCollection.IsOn;
        }

        void toggleTheme_Toggled(object sender, RoutedEventArgs e)
        {
            MessageService.Current.CurrentTheme = !toggleTheme.IsOn ? ElementTheme.Light : ElementTheme.Dark;
        }
    }
}
